package com.weaponlin.domain.collections;

public class OtherTest {

    public static void main(String[] args) {
//        f(0, 100);
//        final char num1 = 'a';
//        char num2 = num1;
//        System.out.printf("num1: %c, num2: %c", num1, num2);
//        num2 = 'b';
//        System.out.printf("num1: %c, num2: %c", num1, num2);

//        final Person p1 = new Person("a");
//        Person p2 = p1;
//        System.out.println(p1);
//        System.out.println(p2);
//
//        p2.setName("b");
//        System.out.println(p1);
//        System.out.println(p2);
//

//        final String str1 = "a";
//        String str2 = str1;
//        String str3 = str2;
//        System.out.println(str1 == str2);
//        System.out.println(str1 == str3);
        String str0 = "a";
        String str1 = new String(str0);
        String str2 = "a";
        System.out.println(str0 == str2);
        String str3 = new String("a");
        System.out.println(str1 == str2);
        System.out.println(str1 == str3);
    }

    static class Person {
        private String name ;

        public Person(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    '}';
        }
    }

    public static void f(int index0, int total) {
        int index = index0;
        while (index < total) {
            int end = 0;
            if ((index + 10) < total) {
                end = index + 10;
            } else {
                end = total;
            }
            String[] tmp = doGenerate(index, end);
            for (String s : tmp) {
                System.out.print(s + " ");
            }
            System.out.println();
            index = end;
        }
    }

    public static String[] doGenerate(int start, int end) {
        String[] ticketIds = new String[end - start];
        for (int i = start; i < end; i++) {
            ticketIds[i - start] = String.valueOf(i + 1);
        }
        return ticketIds;
    }
}
